package com.pine.dbant.common.plugin;

import lombok.Getter;
import lombok.Setter;

import java.util.HashMap;

/**
 * 操作参数
 *
 * @author xiaoyuan
 * @create 2022/11/8 14:43
 **/
@Getter
@Setter
public class QueryExecuteParams extends ExecuteParams<QueryExecuteParams> {
    /**
     * 页码
     */
    private Integer pageIndex = 1;
    /**
     * 每次查询数量
     */
    private Integer pageSize = 10;


    /**
     * 查询条件
     */
    private String whereCriteria;

    /**
     * 排序条件
     */
    private String orderCriteria;


    /**
     * 是否进行分页查询：分页将返回更少的数据
     */
    private boolean noPage = false;

    @Override
    public QueryExecuteParams copy(){
        QueryExecuteParams executeParams = new QueryExecuteParams();
        executeParams.setScript(getScript());
        if(getProperties()!=null){
            executeParams.setProperties(new HashMap<>(getProperties()));
        }
        executeParams.setNoPage(this.noPage);
        executeParams.setPageIndex(this.pageIndex);
        executeParams.setPageSize(this.pageSize);
        executeParams.setWhereCriteria(this.whereCriteria);
        executeParams.setOrderCriteria(this.orderCriteria);
        return  executeParams;
    }


}
